﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OrionApplication.OrionLib.Orion;
using OrionApplication.OrionForm.Dialog;
using System.Runtime.Remoting.Messaging;
using OrionApplication.OrionLib;
using OrionApplication.OrionLib.Dao;
using System.Windows.Forms;
using ComponentFactory.Krypton.Toolkit;

namespace OrionApplication.OrionLib.Orion
{
    public class OrionOutils : OrionOutilsBase
    {
        /// <summary>
        ///
        /// </summary>
        /// <param name="IdentMessage"></param>
        /// <param name="Connecte"></param>
        public static void Alerte(string IdentMessage, bool Connecte = true)
        {
            OrionMessage om = new DaoOrionMessage().SelectByIdent(IdentMessage);
            if (Connecte)
                KryptonMessageBox.Show(om.Message, ((OrionUser)CallContext.GetData(OrionConfBase.OrionUserConnected)).Login + " : " + om.IdentMessage, MessageBoxButtons.OK, MessageBoxIcon.Information);
            else
                KryptonMessageBox.Show(om.Message, om.IdentMessage, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        /// <summary>
        ///
        /// </summary>
        /// <param name="IdentMessage"></param>
        /// <param name="Connecte"></param>
        public static void Alerte(string IdentMessage, List<string> lParam, bool Connecte = true)
        {
            OrionMessage om = new DaoOrionMessage().SelectByIdent(IdentMessage);
            if (Connecte)
            {
                foreach (string s in lParam)
                {
                    om.Message = System.String.Format(om.Message, s);
                }
                KryptonMessageBox.Show(om.Message, ((OrionUser)CallContext.GetData(OrionConfBase.OrionUserConnected)).Login + " : " + om.IdentMessage, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
                KryptonMessageBox.Show(om.Message, om.IdentMessage, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        /// <summary>
        ///
        /// </summary>
        /// <param name="Titre"></param>
        /// <param name="Body"></param>
        /// <param name="Connecte"></param>
        public static void Erreur(string Titre, string Body, bool Connecte = true)
        {
            if (Connecte)
                KryptonMessageBox.Show(Body, ((OrionUser)CallContext.GetData(OrionConfBase.OrionUserConnected)).Login + " : " + Titre, MessageBoxButtons.OK, MessageBoxIcon.Error);
            else
                KryptonMessageBox.Show(Body, Titre, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        /// <summary>
        ///
        /// </summary>
        /// <param name="IdentMessage"></param>
        /// <param name="Connecte"></param>
        /// <returns></returns>
        public static DialogResult ChoixOuiNon(string IdentMessage, bool Connecte = true)
        {
            OrionMessage om = new DaoOrionMessage().SelectByIdent(IdentMessage);

            KryptonTaskDialog ktd = new KryptonTaskDialog();
            ktd.CommonButtons = TaskDialogButtons.Yes | TaskDialogButtons.No;
            ktd.Content = om.Message;
            ktd.Icon = MessageBoxIcon.Question;
            if (Connecte)
                ktd.WindowTitle = ((OrionUser)CallContext.GetData(OrionConfBase.OrionUserConnected)).Login + " : " + om.IdentMessage;
            else
                ktd.WindowTitle = (om.IdentMessage);

            return ktd.ShowDialog();
        }
    }
}